package com.cyt.web.controller.work.wb.phone;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import com.alibaba.fastjson.JSONArray;
import com.cyt.base.json.JSON;
import com.cyt.base.json.JSONObject;
import com.cyt.base.model.dto.ReturnResult;
import com.cyt.base.util.BaseUtil;
import com.cyt.base.util.DictCode;
import com.cyt.base.util.ErrorCode;
import com.cyt.base.util.ProProperties;
import com.cyt.reward.model.po.RewardShop;
import com.cyt.reward.model.po.RewardStaff;
import com.cyt.reward.model.vo.*;
import com.cyt.reward.service.*;
import com.cyt.reward.util.RewardDictCode;
import com.cyt.sys.util.FilePathUtil;
import com.cyt.thrid.wechat.model.base.JSTicketShareResponse;
import com.cyt.thrid.wechat.url.WxUrlUtil;
import com.cyt.web.controller.base.PhoneController;
import com.cyt.web.thrid.wechat.WxApiClient;
import com.cyt.web.thrid.wechat.WxMemoryCacheClient;
import com.cyt.work.util.cache.WbDictCode;
import com.cyt.work.wb.model.po.*;
import com.cyt.work.wb.model.vo.*;
import com.cyt.work.wb.service.*;
import com.cyt.wx.model.po.WxAccount;
import com.cyt.wx.model.po.WxApply;
import com.cyt.wx.model.po.WxMember;
import com.cyt.wx.service.WxApplyService;
import com.cyt.wx.service.WxMemberService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 维保移动端
 *
 * @author shengQiang yu
 * @date 2019-11-28 13:45
 */
@RestController
public class PhoneWbController extends PhoneController {
    @Autowired
    private WbServicerService wbServicerService;
    @Autowired
    private WxApplyService wxApplyService;
    @Resource
    private WbRepairRecordService wbRepairRecordService;
    @Resource
    private WbRepairService wbRepairService;
    @Resource
    private WxMemberService wxMemberService;
    @Resource
    private WbDevicesService wbDevicesService;
    @Resource
    private WbBannerService wbBannerService;
    @Resource
    private WbNoticeService wbNoticeService;
    @Resource
    private WxWbRoomService wxWbRoomService;
    @Resource
    private WbUserService wbUserService;

    /**
     * 登录页面
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/login", method = RequestMethod.GET)
    public ModelAndView login(String token, String applyId) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/mobile/wb/login");
        modelAndView.addObject("token", token);
        modelAndView.addObject("applyId", applyId);
        return modelAndView;
    }
    /**
     * 登录
     *
     * @param token token信息
     * @param loginName 登录名
     * @param password 登录密码
     * @param applyId 应用id
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/login",method = RequestMethod.POST)
    public ReturnResult login(String token, String applyId, String loginName, String password){
        return wbUserService.login(acceptToken(token),loginName,password,applyId);
    }
    /**
     * 退出
     *
     * @param userId 会员id
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/exit",method = RequestMethod.POST)
    public ReturnResult exit(String userId){
        return wbUserService.exit(userId);
    }
    /**
     * 首页
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/index", method = RequestMethod.GET)
    public ModelAndView index(HttpServletRequest request, String token, String applyId) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        //轮播图
        List<WbBanner> wbBannerList=wbBannerService.listExample(new WbBannerVo(applyId));
        //通知公告
        List<WbNotice> wbNoticeList=wbNoticeService.listExampleLimit(new WbNoticeVo(applyId),2);
        modelAndView.setViewName("/mobile/wb/index");
        modelAndView.addObject("wxMember", acceptToken(token));
        modelAndView.addObject("token", token);
        modelAndView.addObject("wbNoticeList",wbNoticeList);
        modelAndView.addObject("wbBannerList",wbBannerList);
        modelAndView.addObject("applyId", applyId);
        modelAndView.addObject("jSTicketShareResponse",Share(request,applyId));
        return modelAndView;
    }
    /**
     * 个人中心
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/my", method = RequestMethod.GET)
    public ModelAndView my(HttpServletRequest request,String token, String applyId) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        WbUser wbUser=(WbUser)map.get("wbUser");
        List<WbRepair> wbRepairList=wbRepairService.listExample(new WbRepairVo(wbUser.getId(),applyId));
        //待分配数量
        int dfpNum=0;
        //待维修数量
        int dwxNum=0;
        //待确认数量
        int dqrNum=0;
        //已完成数量
        int ywcNum=0;
        List<WbRepair> lastRepairList=new ArrayList<>();
        if(wbRepairList!=null&&wbRepairList.size()>0){
            int num=0;
            for(WbRepair wbRepair:wbRepairList){
                if(num<5){
                    lastRepairList.add(wbRepair);
                }
                if(wbRepair.getStatus().equals(WbDictCode.WB_REPAIR_STATUS_DFP)){
                    dfpNum++;
                }else if(wbRepair.getStatus().equals(WbDictCode.WB_REPAIR_STATUS_DWX)){
                    dwxNum++;
                }else if(wbRepair.getStatus().equals(WbDictCode.WB_REPAIR_STATUS_DQR)){
                    dqrNum++;
                }else if(wbRepair.getStatus().equals(WbDictCode.WB_REPAIR_STATUS_WC)){
                    ywcNum++;
                }
            }

        }
        modelAndView.addObject("lastRepairList",lastRepairList);
        modelAndView.addObject("dfpNum",dfpNum);
        modelAndView.addObject("dwxNum",dwxNum);
        modelAndView.addObject("dqrNum",dqrNum);
        modelAndView.addObject("ywcNum",ywcNum);


        modelAndView.setViewName("/mobile/wb/my");
        modelAndView.addObject("wbUser",map.get("wbUser"));
        modelAndView.addObject("wxMember",map.get("wxMember"));
        modelAndView.addObject("token", token);
        modelAndView.addObject("applyId", applyId);
        modelAndView.addObject("jSTicketShareResponse",Share(request,applyId));
        return modelAndView;
    }
    /**
     * 简易维修
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/simpleRepair", method = RequestMethod.GET)
    public ModelAndView simpleRepair(String token, String applyId) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        modelAndView.setViewName("/mobile/wb/simpleRepair");
        modelAndView.addObject("wbUser",map.get("wbUser"));
        modelAndView.addObject("wxMember",map.get("wxMember"));
        modelAndView.addObject("token", token);
        modelAndView.addObject("applyId", applyId);
        return modelAndView;
    }

    /**
     * 报修申请
     *
     * @param token token信息
     * @param wbRepairVo 报修信息
     * @param applyId 应用id
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/createRepair",method = RequestMethod.POST)
    public ReturnResult createRepair(String token, String applyId, WbRepairVo wbRepairVo){
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return new ReturnResult(ErrorCode.CODE_1, "token错误");
        }
        return wbRepairService.createRepair(wbRepairVo,(WbUser) map.get("wbUser"));
    }
    /**
     * 扫描维修
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/saceRepair", method = RequestMethod.GET)
    public ModelAndView saceRepair(String token, String applyId,String roomId,String devicesId) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }

        //设备信息
        if(StrUtil.isNotEmpty(devicesId)){
            List<WbDevices> wbDevicesList=wbDevicesService.selectByCondition(new WbDevicesVo(devicesId));
            if(wbDevicesList!=null&&wbDevicesList.size()>0){
                modelAndView.addObject("wbDevices",wbDevicesList.get(0));
            }
            modelAndView.setViewName("/mobile/wb/deviceRepair");
        }
        //房间信息
        if(StrUtil.isNotEmpty(roomId)){
            WxWbRoom wxWbRoom=wxWbRoomService.selectByPrimaryKey(roomId);
            modelAndView.addObject("wxWbRoom",wxWbRoom);
            modelAndView.setViewName("/mobile/wb/roomRepair");
        }
        modelAndView.addObject("wbUser",map.get("wbUser"));
        modelAndView.addObject("wxMember",map.get("wxMember"));
        modelAndView.addObject("token", token);
        modelAndView.addObject("applyId", applyId);
        return modelAndView;
    }
    /**
     * 分配人-等待分配
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/assignmentList", method = RequestMethod.GET)
    public ModelAndView assignmentList(String token, String applyId,String status) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        if(StrUtil.isEmpty(status)){
            status="0";
        }
        modelAndView.setViewName("/mobile/wb/assignmentList");
        modelAndView.addObject("wbUser",map.get("wbUser"));
        modelAndView.addObject("wxMember", acceptToken(token));
        modelAndView.addObject("token", token);
        modelAndView.addObject("status", status);
        modelAndView.addObject("applyId", applyId);
        return modelAndView;
    }

    /**
     * 我的报修
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/repairList", method = RequestMethod.GET)
    public ModelAndView repairList(String token, String applyId,String status) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        if(StrUtil.isEmpty(status)){
            status="0";
        }
        modelAndView.setViewName("/mobile/wb/repairList");
        modelAndView.addObject("wbUser",map.get("wbUser"));
        modelAndView.addObject("wxMember", acceptToken(token));
        modelAndView.addObject("token", token);
        modelAndView.addObject("status", status);
        modelAndView.addObject("applyId", applyId);
        return modelAndView;
    }
    /**
     * 维修人员
     *
     * @param servicerId    服务id
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/repairUser",method = RequestMethod.POST)
    public ReturnResult repairUser(String applyId,String servicerId){
        List<WbUser> wbUserList=wbUserService.listExample(new WbUserVo(applyId,WbDictCode.WB_USER_TYPE_WXR,servicerId, DictCode.BASE_REMOVE_TAG_NORMAL));
        List<Map<String,Object>> wbUserCode=new ArrayList<>();
        for(WbUser wbUser:wbUserList){
            Map<String,Object> wbUserMap=new HashedMap();
            wbUserMap.put("title",wbUser.getName());
            wbUserMap.put("value",wbUser.getId());
            wbUserCode.add(wbUserMap);
        }
        return new ReturnResult(wbUserCode);
    }
    /**
     * 维修单状态修改
     *
     * @param repairId   维修单id
     * @param repairmanId   维修人id
     * @param servicerId   服务商id
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/assignMentRepair",method = RequestMethod.POST)
    public ReturnResult assignMentRepair(String repairId,String repairmanId,String servicerId){
        WbRepair wbRepair=wbRepairService.selectByPrimaryKey(repairId);
        if(StrUtil.isNotEmpty(repairmanId)){
            WbUser wbUser=wbUserService.selectByPrimaryKey(repairmanId);
            wbRepair.setRepaimanName(wbUser.getName());
            wbRepair.setRepaimanPhone(wbUser.getPhone());
            wbRepair.setRepairmanId(wbUser.getId());
        }
        if(StrUtil.isNotEmpty(servicerId)){
            wbRepair.setServicerId(servicerId);
        }
        wbRepair.setStatus(WbDictCode.WB_REPAIR_STATUS_DWX);
        wbRepair.setUpdateTime(new Date());
        int num=wbRepairService.updateByPrimaryKey(wbRepair);
        if(num>0){
            return new ReturnResult();
        }
        return new ReturnResult(ErrorCode.CODE_1, "分配失败！");
    }
    /**
     * 我的报修
     *
     * @param pageNum          分页数
     * @param pageSize         每页显示条数
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/myRepair",method = RequestMethod.POST)
    public ReturnResult myRepair(WbRepairVo wbRepairVo, int pageNum, int pageSize){
        return wbRepairService.page(wbRepairVo,pageNum,pageSize);
    }
    /**
     * 报修详情
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @param id 报修ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/repairDetail", method = RequestMethod.GET)
    public ModelAndView repairDetail(String token, String applyId,String id) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        WbRepair wbRepair=wbRepairService.selectByPrimaryKey(id);
        if(wbRepair!=null){
            modelAndView.addObject("wbRepairUser",wbUserService.selectByPrimaryKey(wbRepair.getWbUserId()));
            //设备信息
            if(StrUtil.isNotEmpty(wbRepair.getDeviceId())&&WbDictCode.WB_REPAIR_TYPE_SBBX.equalsIgnoreCase(wbRepair.getRepairType())){
                List<WbDevices> wbDevicesList=wbDevicesService.selectByCondition(new WbDevicesVo(wbRepair.getDeviceId()));
                if(wbDevicesList!=null&&wbDevicesList.size()>0){
                    modelAndView.addObject("wbDevices",wbDevicesList.get(0));
                }
            }
            //房间信息
            if(StrUtil.isNotEmpty(wbRepair.getRoomId())&&WbDictCode.WB_REPAIR_TYPE_CDBX.equalsIgnoreCase(wbRepair.getRepairType())){
                WxWbRoom wxWbRoom=wxWbRoomService.selectByPrimaryKey(wbRepair.getRoomId());
                modelAndView.addObject("wxWbRoom",wxWbRoom);
            }
        }
        modelAndView.setViewName("/mobile/wb/repairDetail");
        //获取报修记录
        List<WbRepairRecord> wbRepairRecordList=wbRepairRecordService.listExample(new WbRepairRecordVo(applyId,wbRepair.getId()));
        modelAndView.addObject("wbRepairRecordList", wbRepairRecordList);
        modelAndView.addObject("wbUser",map.get("wbUser"));
        modelAndView.addObject("wxMember", acceptToken(token));
        modelAndView.addObject("wbRepair", wbRepair);
        modelAndView.addObject("token", token);
        modelAndView.addObject("applyId", applyId);
        return modelAndView;
    }

    /**
     * 分配详情
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @param id 报修ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/assignmentDetail", method = RequestMethod.GET)
    public ModelAndView assignmentDetail(String token, String applyId,String id) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        WbRepair wbRepair=wbRepairService.selectByPrimaryKey(id);
        if(wbRepair!=null){
            modelAndView.addObject("wbRepairUser",wbUserService.selectByPrimaryKey(wbRepair.getWbUserId()));
            //设备信息
            if(StrUtil.isNotEmpty(wbRepair.getDeviceId())&&WbDictCode.WB_REPAIR_TYPE_SBBX.equalsIgnoreCase(wbRepair.getRepairType())){
                List<WbDevices> wbDevicesList=wbDevicesService.selectByCondition(new WbDevicesVo(wbRepair.getDeviceId()));
                if(wbDevicesList!=null&&wbDevicesList.size()>0){
                    modelAndView.addObject("wbDevices",wbDevicesList.get(0));
                }
            }
            //房间信息
            if(StrUtil.isNotEmpty(wbRepair.getRoomId())&&WbDictCode.WB_REPAIR_TYPE_CDBX.equalsIgnoreCase(wbRepair.getRepairType())){
                WxWbRoom wxWbRoom=wxWbRoomService.selectByPrimaryKey(wbRepair.getRoomId());
                modelAndView.addObject("wxWbRoom",wxWbRoom);
            }
        }
        //获取报修记录
        List<WbRepairRecord> wbRepairRecordList=wbRepairRecordService.listExample(new WbRepairRecordVo(applyId,wbRepair.getId()));
        List<WbServicer> wbServicerList=wbServicerService.listExample(new WbServicerVo());
        List<Map<String,Object>> servicerCode=new ArrayList<>();
        for(WbServicer wbServicer:wbServicerList){
            Map<String,Object> servicer=new HashedMap();
            servicer.put("title",wbServicer.getName());
            servicer.put("value",wbServicer.getId());
            servicerCode.add(servicer);
        }

        modelAndView.setViewName("/mobile/wb/assignmentDetail");
        modelAndView.addObject("wbRepairRecordList",wbRepairRecordList);
        modelAndView.addObject("servicerCode", JSONArray.toJSONString(servicerCode));
        modelAndView.addObject("wbUser",map.get("wbUser"));
        modelAndView.addObject("wxMember", acceptToken(token));
        modelAndView.addObject("wbRepair", wbRepair);
        modelAndView.addObject("token", token);
        modelAndView.addObject("applyId", applyId);
        return modelAndView;
    }


    /**
     * 维修添加
     *
     * @param wbRepairRecordVo       分页数
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/repairRecord",method = RequestMethod.POST)
    public ReturnResult repairRecord(WbRepairRecordVo wbRepairRecordVo){
        ReturnResult returnResult=wbRepairRecordService.addOrUpdate(wbRepairRecordVo,null);
        if(returnResult.getCode()==0 && WbDictCode.WB_RESULT_STATUS_FX.equals(wbRepairRecordVo.getStatus())){
            //返修同时处理报销单状态
            WbRepair wbRepair=wbRepairService.selectByPrimaryKey(wbRepairRecordVo.getRepairId());
            wbRepair.setUpdateTime(new Date());
            wbRepair.setStatus(WbDictCode.WB_REPAIR_STATUS_DFP);
            wbRepairService.updateByPrimaryKey(wbRepair);
        }
        return returnResult;
    }
    /**
     * 维修确定和完成接口
     *
     * @param repairId    维修记录id
     * @param status   报修单状态（1.待分配 2.待维修 3.返修 4.待确认 5.完成）
     * @param pjContent   评价内容
     * @param pjScore    评价分数
     * @param pjTarget   评价指标
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/repairStatus",method = RequestMethod.POST)
    public ReturnResult repairStatus(String repairId,String status,String pjContent,int pjScore,String pjTarget){
        WbRepair wbRepair=wbRepairService.selectByPrimaryKey(repairId);
        wbRepair.setStatus(status);
        wbRepair.setUpdateTime(new Date());
        if(WbDictCode.WB_REPAIR_STATUS_WC.equals(status)){
            wbRepair.setPjContent(pjContent);
            wbRepair.setPjScore(pjScore);
            wbRepair.setPjTarget(pjTarget);
        }
        int num=wbRepairService.updateByPrimaryKey(wbRepair);
        if(num>0){
            return new ReturnResult();
        }
        return new ReturnResult(ErrorCode.CODE_1, "操作失败！");
    }

    /**
     * 公告页面
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/notice", method = RequestMethod.GET)
    public ModelAndView wbNotice(String token, String applyId) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        modelAndView.setViewName("/mobile/wb/notice");
        modelAndView.addObject("token", token);
        modelAndView.addObject("applyId", applyId);
        return modelAndView;
    }
    /**
     * 公告内容
     *
     * @param pageNum          分页数
     * @param pageSize         每页显示条数
     * @return
     * @author shengQiang yu
     * @date 2019-11-28 16:52
     */
    @RequestMapping(value = "/phone/wb/myNoticePage",method = RequestMethod.POST)
    public ReturnResult myNoticePage(WbNoticeVo wbNoticeVo, int pageNum, int pageSize){
        return wbNoticeService.page(wbNoticeVo,pageNum,pageSize);
    }
    /**
     * 公告详情页面
     *
     * @param id   公告id
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/noticeDesc", method = RequestMethod.GET)
    public ModelAndView wbNoticeDesc(String id) {
        ModelAndView modelAndView = new ModelAndView();
       WbNotice wbNotice=wbNoticeService.selectByPrimaryKey(id);
        modelAndView.setViewName("/mobile/wb/noticeDesc");
        modelAndView.addObject("wbNotice", wbNotice);
        return modelAndView;
    }
    /**
     * 个人信息
     *
     * @param token   用户信息
     * @param applyId 应用ID
     * @return ModelAndView
     * @author shengQiang yu
     * @date 2019-11-28 13:49
     */
    @RequestMapping(value = "/phone/wb/mySet", method = RequestMethod.GET)
    public ModelAndView mySet(String token, String applyId) {
        ModelAndView modelAndView = new ModelAndView();
        Map<String,Object> map=acceptToken(token,applyId,APPLY_TYPE_WB);
        if (!(Boolean) map.get("flag")) {
            return (ModelAndView) map.get("modelAndView");
        }
        modelAndView.setViewName("/mobile/wb/mySet");
        modelAndView.addObject("wbUser",map.get("wbUser"));
        modelAndView.addObject("wxMember", acceptToken(token));
        return modelAndView;
    }
    /**
     * 通用分享可设置
     * */
    public JSTicketShareResponse Share(HttpServletRequest request,String applyId){
        WxApply wxApply = wxApplyService.selectByPrimaryKey(applyId);
        WxAccount wxAccount=WxMemoryCacheClient.getWxAccount(wxApply.getAccountId());
        String url= ProProperties.getInstance().getBaseUrl()+request.getServletPath();
        String c=request.getQueryString();
        if(StringUtils.isNotEmpty(c)){
            url=url+"?"+c;
        }
        //设置js分享
        JSTicketShareResponse jsTicketShareResponse = WxApiClient.getJSTicketShareResponse(wxApply.getAccountId(),url);
        if(jsTicketShareResponse!=null){
            jsTicketShareResponse.setFxTitle("维保");
            jsTicketShareResponse.setFxImgUrl(ProProperties.getInstance().getBaseUrl()+ "/static/weixin/images/logo.png");
            jsTicketShareResponse.setFxDesc("维保描述");
            jsTicketShareResponse.setFxUrl(ProProperties.getInstance().getBaseUrl()+"/weChat/oauth?applyId="+applyId);
            jsTicketShareResponse.setAppid(wxAccount.getAppId());
        }

        return jsTicketShareResponse;
    }
}